using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;

namespace Wips.AppService.Authorities.Permissions.Requests
{
    /// <summary>
    /// 保存权限请求类
    /// </summary>
    public class SavePermissionRequest : IRequest<bool>, ITxRequest
    {
        /// <summary>
        /// 角色Id
        /// </summary>
        public string RoleId { get; set; } = "";




        /// <summary>
        /// 菜单Ids
        /// </summary>
        public IList<string> MenuIds { get; set; } = new List<string>();

        /// <summary>
        /// 操作Ids
        /// </summary>
        public IList<string> OperationIds { get; set; } = new List<string>();
    }

    /// <summary>
    /// 
    /// </summary>
    public class SavePermissionValidator : AbstractValidator<SavePermissionRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public SavePermissionValidator()
        {
            RuleFor(p => p.RoleId)
                .Must(id => !string.IsNullOrEmpty(id))
                .WithMessage("角色不能为空");

      

            RuleFor(p => p.MenuIds)
                .Must(ids => ids != null)
                .WithMessage("菜单不能为null");

            RuleFor(p => p.OperationIds)
                .Must(ids => ids != null)
                .WithMessage("操作不能为null");
        }
    }
}